package com.book.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Result<T> {
    private String esg;
    private String code;
    private T data;

    public Result(String esg, String code) {
        this.esg = esg;
        this.code = code;
    }

    public static com.book.result.Result OK(){
        return new com.book.result.Result(com.book.result.ResultEnum.SUCCESS.getCode(), com.book.result.ResultEnum.SUCCESS.getSmg());
    }
    public static com.book.result.Result FAIL(){
        return new com.book.result.Result(com.book.result.ResultEnum.FAIL.getCode(), com.book.result.ResultEnum.FAIL.getSmg());
    }

    public static com.book.result.Result response(ResultEnum resultEnum){
        return new com.book.result.Result(resultEnum.getCode(),resultEnum.getSmg());
    }
}
